﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Eis51.CampanyCMS.Business.NewsManager;
using Eis51.CampanyCMS.Business;
using Eis51.CampanyCMS.FrameWork;
using Eis51.CampanyCMS.Model.NewsManager;
using Eis51.CampanyCMS.Business.Bus;

using Eis51.CampanyCMS.Model;

namespace Eis51.Web.Admin.NewsManager
{
    public partial class CustomerTypeAdd : BasePage
    {


        /// <summary>
        /// NewsID 0:新增/否则修改
        /// </summary>
        private string seqno
        {
            get
            {
                if (Request["seqno"] == null)
                {
                    return "0";
                }
                else
                {
                    return (string)Request["seqno"];
                }
            }
        }



        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //lblcid.Text = AppContext.LcidCnName(AppContext.LCID);

                //CustomerTypeBLL.BindDropListTreeType(ddlTypeParents, "");
                //ddlTypeParents.Items.Insert(0, new ListItem("请选择", "0"));
                if (this.seqno != "0")
                {
                    CustomerType newstype = CustomerTypeBLL.GetInstance().Get(new CustomerType.Key(int.Parse(this.seqno)));
                    //BaseTools.SetListControl(ddlTypeParents, newstype.Parentid.ToString());                    
                    txtNewsTypeName.Text = newstype.Title;
                    txtShowContent.Text = newstype.Showcontent;
                    //news.Type = int.Parse(drList.SelectedValue);
                    // content1.Value = news.Content;
                }
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            CustomerType newstype = null;
            if (string.Empty.Equals(txtNewsTypeName.Text.Trim()))
            {
                Response.Write("<script>alert('类型名称不能为空');</script>");
                return;
            }
            if (this.seqno != "0")
            {
                newstype = CustomerTypeBLL.GetInstance().Get(new CustomerType.Key(int.Parse(this.seqno)));
            }
            else
            {
                newstype = new CustomerType();
                newstype.Licd = AppContext.LCID;//新增
            }            
            newstype.Title = txtNewsTypeName.Text;
            newstype.Showcontent = txtShowContent.Text;
            //newstype.Parentid = CType.ToInt(ddlTypeParents.SelectedValue);
            CustomerTypeBLL.GetInstance().SubMit(newstype);
            btnReturn_Click(null, null);
        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            Response.Redirect("CustomerTypeList.aspx");
        }
    }
}
